home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_iiput.asp < prev    next >
Encoding:
Text File  |  1999-06-03  |  8.3 KB  |  335 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <% Option Explicit %>
  3. <!-- #include file="directives.inc" -->
  4.  
  5. <!--#include file="iiput.str"-->
  6.  
  7. <%
  8. Const ADS_PROPERTY_CLEAR = 1
  9. Const IIS_DATA_INHERIT = 1
  10. Const IISAO_WEB_SERVICE_CLASS = "IIsWebService"
  11. %>
  12.  
  13. <HTML>
  14. <HEAD>
  15.  
  16.  
  17. <% 
  18. On Error Resume Next 
  19.  
  20. Dim path, lasterr, currentobj, key, sobj, specprops, newval,dirkeyType
  21. Dim changed, objname, thisobj, value, bval, curval,quote, childpath, aSetChildPaths
  22. Dim clearPaths, child, proparray
  23. dirkeyType = "IIsWebDirectory"
  24. quote = chr(34)
  25.  
  26. lasterr=""
  27. path=Session("path")
  28. 'Response.write path
  29.  
  30. if Session("clearPathsOneTime") <> "" then 
  31.     clearPaths = Session("clearPathsOneTime")
  32. else
  33.     clearPaths = (Session("clearPaths") <> "")
  34. end if
  35. 'Response.write hex(err)
  36.  
  37. 'Response.write clearPaths
  38. Set currentobj=GetObject(path)
  39.  
  40. %>
  41. <!--#include file="iifixpth.inc"-->
  42. <%
  43.  
  44. specprops = "SERVERBINDINGS,HTTPEXPIRES,GRANTBYDEFAULT,MSDOSDIROUTPUT," & _
  45.             "HCDOSTATICCOMPRESSION,HCDODYNAMICCOMPRESSION,HCCOMPRESSIONDIRECTORY," & _
  46.             "HCDODISKSPACELIMITING,HCMAXDISKSPACEUSAGE,APPISOLATED"
  47.  
  48. 'Response.write "SpecObj - " & Session("SpecObj") & "<BR>"
  49. 'Response.write "SpecProps - " & Session("SpecProps") & "<BR>"
  50. 'Response.write "currentobj - " & currentobj.ADsPath & "<BR>"
  51.  
  52. changed=false
  53.  
  54. For Each key In Request.QueryString
  55.     key = UCase(key)
  56.     changed=false
  57. '    Response.write "key - " & key & "<BR>"
  58.     if (key <>"PAGE" ) and (key <> "STATE") and  (key <> "CLEARPATHS")  then
  59.         if inStr(specprops,key) <> 0 then
  60.             
  61.             ' Special properties
  62.             err.Clear
  63.             value=Request.QueryString(key)
  64.  
  65.             Select Case UCase(key)
  66.             Case "GRANTBYDEFAULT" 
  67.  
  68.                 Set thisobj = currentobj.Get( "IPSecurity" )
  69.                 bval = CBool(value)
  70.                 if thisobj.GrantByDefault <> bval then
  71.                     thisobj.GrantByDefault = bval
  72.                     currentobj.IPSecurity=thisobj
  73.                     currentobj.SetInfo
  74.                     changed = True
  75.                 end if
  76.             
  77.             Case "HTTPEXPIRES"
  78.  
  79.                 Set thisobj = currentobj
  80.                 if value = "d,-1" then            
  81.                     changed = true                    
  82.                     thisobj.HttpExpires = ""
  83.                 else
  84.                     changed = writeStdProp(thisobj, key)
  85.                 end if
  86.                 thisobj.SetInfo
  87.  
  88.             Case "SERVERBINDINGS"            
  89.  
  90.                 Set thisobj = currentobj
  91.                 Dim bindings
  92.                 bindings = split(value,",")
  93.                 if chkUpdated(thisobj.ServerBindings,bindings) then
  94.                     thisobj.Put key, (bindings)
  95.                     changed = true
  96.                 end if
  97.                 thisobj.SetInfo
  98.  
  99.             Case "MSDOSDIROUTPUT"
  100.                 
  101.                 Set thisobj = GetObject( currentobj.Parent )
  102.                 changed = writeStdProp(thisobj, key)                
  103.                 thisobj.SetInfo
  104.  
  105.             Case "HCDOSTATICCOMPRESSION", "HCDODYNAMICCOMPRESSION", _
  106.                  "HCCOMPRESSIONDIRECTORY", "HCDODISKSPACELIMITING", _
  107.                  "HCMAXDISKSPACEUSAGE"
  108.                 
  109.                 Set thisobj = GetObject( "IIS://localhost/w3svc/Filters/Compression/Parameters" )
  110.                 changed = writeStdProp(thisobj, key)                
  111.                 thisobj.SetInfo
  112.             
  113.             Case "APPISOLATED"
  114.                 set thisobj = currentobj
  115.                 
  116. '                Response.write thisobj.ADsPath & "<BR>"
  117. '                Response.write thisobj.Name & "<BR>"
  118. '                Response.write thisobj.Class & "<BR>"
  119.                 
  120.                 ' Is this actually an application?
  121.                 ' Has the value of AppIsolated changed?
  122.                 newval = CInt(Request.QueryString(key))
  123.                 curval = thisobj.Get(key)
  124.                 
  125. '                Response.write "newval - " & newval & " "
  126. '                Response.write "curval - " & curval & "<BR>"
  127.  
  128.                 if isApplication( thisobj ) And newval <> curval then
  129.                     if clearPaths then
  130.                          thisobj.AppDeleteRecursive
  131. '                        Response.write "thisobj.AppDeleteRecursive" & "<BR>"
  132. '                        Response.write "Err.Number = " & Hex(Err.Number) & "<BR>"
  133.                     end if
  134.                     thisobj.AppCreate2 newval
  135. '                    Response.write "thisobj.AppCreate2 " & newval & "<BR>"
  136. '                    Response.write "Err.Number = " & Hex(Err.Number) & "<BR>"
  137.                 elseif thisobj.Class = IISAO_WEB_SERVICE_CLASS then
  138.                     changed = writeStdProp(thisobj, key)
  139.                 end if
  140.  
  141.                 ' Set as unchanged to prevent the path clear from actually modifying
  142.                 ' this property
  143.                 changed = False
  144.             Case Else
  145.  
  146.                 ' This is really an error, but we'll try anyway
  147.                 Set thisobj = currentobj
  148.                 changed = writeStdProp(thisobj, key)                
  149.                 thisobj.SetInfo
  150.  
  151.             End Select
  152.             
  153.         else
  154.  
  155.             ' Standard properties
  156.             Set thisobj=currentobj
  157.             newval=Request.QueryString(key)        
  158.             curval=thisobj.Get(key)
  159.  
  160.             if not isArray(curval) then
  161.                 changed = writeStdProp(thisobj, key)
  162.             else
  163.                 ReDim proparray(0)
  164.                 proparray(0) = newval
  165.                 
  166.                 if chkUpdated(curval,proparray) then
  167.                      thisobj.Put key, (proparray)
  168.                      changed = True
  169.                 end if
  170.             end if            
  171.  
  172.             thisobj.SetInfo
  173.  
  174.         end if
  175.     end if
  176.  
  177.     err.clear
  178.     if changed then
  179.         if clearPaths then
  180. '            Response.write thisobj.ADSPath & "<BR>"        
  181. '            Response.write "Name:" & thisobj.ADsPath & "<BR>"
  182. '            Response.write key & "<BR>"
  183.  
  184.             aSetChildPaths = thisobj.GetDataPaths(key,IIS_DATA_INHERIT) 
  185. '            Response.write hex(err)
  186.             
  187.             if err = 0 then
  188.                 For Each childpath in aSetChildPaths
  189. '                    Response.write childpath & "<BR>"
  190.                     childPath = cleanPath(childPath)
  191.                 
  192.                     Set child = GetObject(childpath)
  193.                     if child.ADSPath <> thisobj.ADSPath then
  194.                         if (instr(LCase(child.ADSPath), "IIS://localhost/w3svc/info") > 0) OR (instr(LCase(child.ADSPath), "IIS://localhost/msftpsvc/info") > 0) then
  195.                         else
  196.                             child.PutEx ADS_PROPERTY_CLEAR, key, ""
  197.                             child.SetInfo
  198.                         end if
  199.                     end if
  200.                 Next    
  201.             end if
  202.             err = 0
  203.         end if
  204.     end if
  205. Next
  206.  
  207. currentobj.SetInfo
  208.  
  209. ' BUGBUG - Same function defined in iicache2.asp, should share the
  210. ' same implementation.
  211. function isApplication( objWebNode )
  212.     On Error Resume Next
  213.     
  214.     dim bReturn, strAppRoot, strADsPath
  215.  
  216.     bReturn = False
  217.     strAppRoot = UCase(objWebNode.AppRoot)
  218.     if strAppRoot <> "" then
  219.         ' The AppRoot is inherited, if there is really an application
  220.         ' defined at this node, the paths will point to the same node.
  221.         strADsPath = UCase(objWebNode.ADsPath)
  222.         
  223.         strAppRoot = Mid(strAppRoot,Instr(strAppRoot,"W3SVC/")+1)
  224.         strADsPath = Mid(strADsPath,Instr(strADsPath,"W3SVC/")+1)
  225.  
  226.         if strADsPath = strAppRoot then
  227.             bReturn = True
  228.         end if
  229.     end if
  230.     isApplication = bReturn
  231. end function
  232.  
  233. Function writeStdProp(thisobj, key)
  234.  
  235.     dim curval, newval
  236.     
  237.     newval=Request.QueryString(key)
  238.     curval=thisobj.Get(key)
  239.     
  240. '    Response.write "newval - " & newval & " "
  241. '    Response.write "curval - " & curval & "<BR>"
  242.     
  243.     Select Case typename(curval)
  244.         Case "Boolean" 
  245.             value = (UCase(newval) = "TRUE")
  246.         Case "Long"
  247.             value = cLng(newval)
  248.         Case Else
  249.             value = newval
  250.     End Select
  251.  
  252.     if curval <> value then
  253.         thisobj.Put key, (value)
  254.         writeStdProp = True            
  255.     else
  256.         writeStdProp = False
  257.     end if    
  258. End Function
  259.  
  260. Function cleanPath(pathstr)
  261.     if Right(pathstr,1) = "/" then
  262.         pathstr = Mid(pathstr, 1,len(pathstr)-1)
  263.     end if
  264.     cleanPath = pathstr
  265. End Function
  266.  
  267. Function chkUpdated(oldarray,proparray)
  268.  
  269.     dim proparraybound,arrayWasUpdated, i
  270.     
  271.     if IsArray(oldarray) then
  272.         proparraybound=UBound(proparray)
  273.         if UBound(oldarray) <> proparraybound then
  274.             arrayWasUpdated=true
  275.         else
  276.             for i=0 to proparraybound
  277.                 if oldarray(i) <> proparray(i) then                    
  278.                     arrayWasUpdated=true
  279.                 end if
  280.             Next
  281.         end if
  282.     else        
  283.         if proparraybound > 0 then
  284.             arrayWasUpdated=true
  285.         else
  286.             arrayWasUpdated=(proparray(0) <> oldarray)            
  287.         end if
  288.     end if
  289.     
  290.     'set our global changed var
  291.     changed = arrayWasUpdated
  292.     
  293.     chkUpdated = arrayWasUpdated
  294.     
  295. End Function
  296.  
  297. %>
  298.  
  299. </HEAD>
  300.  
  301. <BODY BGCOLOR="#000000" TEXT="#FFCC00" TOPMARGIN=0 LEFTMARGIN=0>
  302. <SCRIPT LANGUAGE="JavaScript">
  303.  
  304.     <% if Request.QueryString("PAGE") <> "popup" then %>
  305.     top.title.Global.updated=false;
  306.     if (top.body.frames.length > 0){    
  307.         <% if Request("ServerComment") <> "" then %>
  308.         top.title.nodeList[top.title.Global.selId].title="<%= Request("ServerComment") %>";
  309.         if (top.body.menu != null){
  310.             top.body.menu.location.href=top.body.menu.location.href;
  311.         }
  312.         <% end if %>
  313.         
  314.  
  315.         if (top.body.frames.length > 3){
  316.         <% if Session("IsIE") then %>
  317.             top.body.iisstatus.location.href="iistat.asp?thisState=" + escape("<%= L_CHANGESSAVED_TEXT %>");
  318.         
  319.         <% else %>
  320.             top.body.frames[3].location.href="iistat.asp?thisState=" + escape("<%= L_CHANGESSAVED_TEXT %>");
  321.         <% end if %>            
  322.         }
  323.         else{
  324.             if (top.body.iisstatus != null){    
  325.                 top.body.iisstatus.location.href="iistat.asp?thisState=" + escape("<%= L_CHANGESSAVED_TEXT %>");
  326.             }
  327.         }
  328.     }    
  329.     <% end if %>
  330.     
  331. </SCRIPT>
  332.  
  333. </BODY>
  334. </HTML>
  335.